home *** CD-ROM | disk | FTP | other *** search
/ PC Open 103 / PC Open 103 CD 1.bin / CD1 / INTERNET / WEBDESIGN / Tsw WebCoder / tswwebcoder5en.exe / {app} / scripts / scriptcode / quicktable.tss < prev    next >
Encoding:
Text File  |  2004-04-26  |  2.1 KB  |  93 lines

  1. {
  2. [Scriptsettings]
  3. Scriptname=Quick Table
  4. ExecuteOnStartup=0
  5. ExecuteOnlyOnce=0
  6. }
  7.  
  8. program QuickTable;
  9. var
  10.  Column, Row: integer;
  11.  LblCaption: TLabel;
  12.  F: TForm; 
  13.  
  14. procedure GridMouseClick(Sender: TObject);
  15. var
  16.  i,j: integer;
  17.  Code:string;
  18. begin
  19.  Code := '<table>'+#13#10;
  20.  for I := 0 to Row do
  21.   begin
  22.    Code := Code + #9+'<tr>'+#13#10;
  23.    for J:= 0 to Column do
  24.     begin
  25.      Code := Code + #9#9+'<td></td>'+#13#10;
  26.     end;
  27.    Code := Code + #9'</tr>'+#13#10;
  28.   end;
  29.  Code := Code + '</table>';
  30.  InsertTags(Code, '');
  31.  F.Close;
  32. end; 
  33.  
  34. procedure GridMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
  35. var
  36.  Grid: TStringGrid;
  37.  myRect: TGridRect; 
  38. begin
  39.  Grid := (Sender as TStringGrid);
  40.  try
  41.   Grid.MouseToCell(X, Y, Column, Row);
  42.   myRect := Grid.Selection;
  43.   myRect.Left := 0;
  44.   myRect.Right := Column;
  45.   myRect.Top := 0;
  46.   myRect.Bottom := Row;
  47.   Grid.Selection := myRect;
  48.   
  49.   If Column + 1 = Grid.ColCount - 1 then
  50.    begin
  51.     Grid.ColCount := Grid.ColCount+1;
  52.     Grid.Width := Grid.Width + 23;
  53.     F.Width := F.Width + 25;
  54.    end;
  55.   If Row + 1 = Grid.RowCount - 1 then
  56.    begin
  57.     Grid.RowCount := Grid.RowCount+1;
  58.     Grid.Height := Grid.Height + 23;
  59.     F.Height := F.Height + 25;
  60.    end;            
  61.   LblCaption.Caption := (IntToStr(Column+1)) + ' x ' + (IntToStr(Row+1)+' table');
  62.  except
  63.   exit;
  64.  end;
  65. end;
  66.  
  67. var
  68.  SG: TStringGrid;
  69. begin
  70.  F := TForm.Create(nil);
  71.  F.Caption := 'QuickTable';
  72.  F.BorderStyle := bsToolWindow;
  73.  SG := TStringGrid.Create(F);
  74.  SG.Parent := F;
  75.  SG.Align := alClient;
  76.  SG.FixedCols := 0;
  77.  SG.FixedRows := 0; 
  78.  SG.DefaultRowHeight := 24;
  79.  SG.DefaultColWidth := 24; 
  80.  SG.RowCount := 5;
  81.  SG.ColCount := 5;
  82.  SG.Options := SetOf([goFixedVertLine, goFixedHorzLine, goVertLine, goHorzLine, goRangeSelect, goDrawFocusSelected, goAlwaysShowEditor]);
  83.  SG.OnMouseMove := 'GridMouseMove';
  84.  SG.OnClick := 'GridMouseClick';
  85.  F.ClientWidth := 130;
  86.  F.ClientHeight := 150; 
  87.  LblCaption := TLabel.Create(F);
  88.  LblCaption.Parent := F;
  89.  LblCaption.Align := alBottom;
  90.  F.ShowModal;
  91.  F.Release;
  92. end;
  93.